package com.tledu.spring06.model;

import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Component;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * @author Antg
 * @date 2021/8/10  10:54
 */
@Component
public class UserRowMapper implements RowMapper<User> {
    @Override
    public User mapRow(ResultSet resultSet, int i) throws SQLException {
        User user = new User();
        user.setId(resultSet.getInt("id"));
        user.setUsername(resultSet.getString("username"));
        user.setPassword(resultSet.getString("password"));
        user.setNickname(resultSet.getString("nickname"));
        user.setBirthday(resultSet.getDate("birthday"));
        user.setAge(resultSet.getInt("age"));
        user.setCreateBy(resultSet.getString("create_by"));
        user.setCreateTime(resultSet.getDate("create_time"));
        return user;
    }
}
